package vip.hello520.controller;

import com.alibaba.fastjson.JSON;
import vip.hello520.model.ResultBean;
import vip.hello520.model.ResultEnum;

public class BaseController {

    /**
     * 常规操作成功
     *
     * @return
     */
    protected String resultSuccess() {
        ResultBean resultBean = new ResultBean();
        resultBean.setState(ResultEnum.SUCCESS.getStateInt());
        resultBean.setMessage(ResultEnum.SUCCESS.getStateStr());
        return JSON.toJSONString(resultBean);
    }

    /**
     * 常规操作失败
     *
     * @return
     */
    protected String resultFailure() {
        ResultBean resultBean = new ResultBean();
        resultBean.setState(ResultEnum.FAILURE.getStateInt());
        resultBean.setMessage(ResultEnum.FAILURE.getStateStr());
        return JSON.toJSONString(resultBean);
    }
}
